package ml.kgc.service.impl;

import ml.kgc.dao.NewsCategoryDao;
import ml.kgc.dao.NewsDao;
import ml.kgc.dao.impl.NewsCategoryDaoImpl;
import ml.kgc.dao.impl.NewsDaoImpl;
import ml.kgc.pojo.NewsCategory;
import ml.kgc.service.NewsCategoryService;

public class NewsCategoryServiceImpl implements NewsCategoryService {
    private NewsDao newsDao;
    private NewsCategoryDao newsCategoryDao;

    public NewsCategoryServiceImpl() {
        newsDao = new NewsDaoImpl();
        newsCategoryDao = new NewsCategoryDaoImpl();
    }

    public boolean deleteNewsCategory(NewsCategory newsCategory) {
        Boolean flag = false;
        int count = newsDao.getCountByCateory(newsCategory);
        if(count > 0){
            System.out.println("无法删除该分类，该分类下还有新闻呢！！");
        }else {
            flag = newsCategoryDao.deleteNewsCategory(newsCategory);
            System.out.println("新闻分类表删除成功！");
        }
        return false;
    }




}
